package shuixian.jing.discuz.activity.base;

import shuixian.jing.discuz.R;
import shuixian.jing.discuz.activity.ActivitySpaceMe;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class FrameActivity extends BaseActivity {
	
	//用户功能列表
	private ImageView mImageViewFunc;
	//搜索功能列表
	private ImageView mImageViewGroup;
	private LinearLayout mLinearLayoutCenterMain;
	private LinearLayout mLinearLayoutFriendMain;
	private int mScrollX = 0;
	private int mWinWidth = 0;
	private int mHiddenWidth = 80;
	private int mFlag = 0;
	
	//导航用户头像
	private ImageView mImageViewModuleNavUsericon ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		//屏蔽EditText制动获得焦点，弹出输入法
		getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
	}
	
	/**
	 * 设置中间内容
	 * @param resId  资源ID
	 */
	protected void addCenterView(int  resId) {
		LinearLayout centerMain = (LinearLayout) findViewById(R.id.LinearLayout_center_main);
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		View _View = LayoutInflater.from(this).inflate(resId, null);
		centerMain.addView(_View, params);
	}
	
	/**
	 * 初始化View
	 */
	protected void initView() {
		mLinearLayoutCenterMain = (LinearLayout) findViewById(R.id.LinearLayout_center_main);
		mLinearLayoutFriendMain = (LinearLayout) findViewById(R.id.LinearLayout_friend__main);
		
		mImageViewFunc = (ImageView) findViewById(R.id.ImageViewFunc);
		mImageViewGroup = (ImageView) findViewById(R.id.ImageViewGroup);
		
		//导航
		mImageViewModuleNavUsericon = (ImageView)findViewById(R.id.module_nav_usericon);
	}

	/**
	 * 初始化变量
	 */
	protected void initVariable() {

		mWinWidth = getDisplay().getWidth();
		
	}

	/**
	 * 初始化监听器
	 */
	protected void initListeners() {
		
		mImageViewFunc.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				//隐藏搜索
				mLinearLayoutFriendMain.setVisibility(View.GONE);
				if (mFlag == 0) {
					mScrollX = mHiddenWidth - mWinWidth;
					mFlag = 1;
				} else {
					mScrollX = 0;
					mFlag = 0;
				}
				showToast("mWinWidth::"+mWinWidth+"  mScrollX"+mScrollX);
				//滚动layout
				mLinearLayoutCenterMain.scrollTo(mScrollX, 0);

			}
		});

		mImageViewGroup.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				//显示搜索
				mLinearLayoutFriendMain.setVisibility(View.VISIBLE);
				if (mFlag == 0) {
					mScrollX = mWinWidth - mHiddenWidth;
					mFlag = 1;
				} else {
					mScrollX = 0;
					mFlag = 0;
				}
				showToast("mWinWidth::"+mWinWidth+"  mScrollX"+mScrollX);	
				mLinearLayoutCenterMain.scrollTo(mScrollX, 0);

			}
		});
		//点击头像设置个人信息
		mImageViewModuleNavUsericon.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(FrameActivity.this, ActivitySpaceMe.class));
			}
		});
		
	}

	/**
	 * 绑定数据
	 */
	protected void bindData() {

	}

}
